<?php

namespace api\article\controller;

class AdminIndexController extends \Aaa\article\controller\AdminIndexController {

    protected $baseField = [
        [
            'field' => 'id',
            'name' => 'ID',
        ],
        [
            'field' => 'category_id',
            'name' => '分类',
            'type' => 'select',
            'options' => [
                ['name' => '无', 'value' => 0],
            ],
            'optionsSource' => [
                'table' => 'article_category',
                'nameField' => 'name',
                'valueField' => 'id',
            ],
        ],
        [
            'field' => 'title',
            'name' => '标题',
        ],
        [
            'field' => 'content',
            'name' => '内容',
            'type' => 'richText',
            'remark' => "注意：为了兼容H5、APP、小程序，请不要设置太多格式。富文本框的图片是base64编码存储到数据库，所以富文本框内容尽量不要添加图片。如果添加，请用ps等工具压缩到20KB以内，否则极大影响数据查询和体验。",
        ],
        [
            'field' => 'list_order',
            'name' => '排序',
        ],
    ];

    protected function beforeIndex() {
        $this->actionField = ['id', 'category_id', 'title', 'list_order',];
        $this->searchField = [
            'common' => [
                'id' => 'accurate',
                'title' => 'fuzzy',
                'category_id' => 'accurate',
            ],
        ];
    }

    protected function beforeAdd() {
        $this->actionField = ['category_id', 'title', 'content', 'list_order',];
    }

    protected function beforeEdit() {
        $this->beforeAdd();
    }


}
